package com.leejxx.backend.controller;

import com.leejxx.blog.service.SmsService;
import com.leejxx.common.consts.MessageConst;
import com.leejxx.common.entity.Result;
import com.leejxx.common.entity.SmsTask;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author LeeJx
 * @ClassName ValidateCodeController
 * @Description TODO
 * @date 2021/2/13 0:24
 * @Version 1.0
 */
@RestController
@Slf4j
@RequestMapping("/validateCode")
public class ValidateCodeController {
    @DubboReference
    private SmsService smsService;

    @RequestMapping("/send")
    public Result send(SmsTask smsTask) {
        log.info("[验证码-发送type:{},phoneNumber:{}]", smsTask.getType(), smsTask.getPhoneNumber());
        smsService.sendValidateCode(smsTask.getType(),smsTask.getPhoneNumber());
        return new Result(true, MessageConst.SEND_VALIDATE_CODE_SUCCESS);
    }
}
